<?php include_once('header.php'); ?>
<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try {
				ace.settings.check('breadcrumbs', 'fixed')
			} catch (e) {}
		</script>
		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				会员管理
			</li>
			<li>
				会员业绩统计
			</li>
		</ul>
	</div>
	<div class="page-content">
	
		<div class="page-header" style="height:40px;"></div>
		<div class="page-header">
			<h1 class="blue"><i class="icon-edit"></i>会员业绩统计</h1>
		</div>
		<div class="visible-md visible-lg hidden-sm hidden-xs btn-group" style="margin-bottom:20px;">
			<form action="/admin/user_yeji/index" method="post" style="display: initial;">
				<input type="hidden" id="user_id" name="user_id" value="<?php echo $user_id; ?>" />
				<label style="padding-left:10px;font-size:13px;">账户</label>
				<input type="text" id="username" name="username" style="width: 100px;" value="<?php echo $username; ?>" />
				<label style="padding-left:10px;font-size:13px;">团队业绩>=</label>
				<input type="text" id="tuandui" name="tuandui" style="width: 100px;" value="<?php echo $tuandui; ?>" />
				<label style="padding-left:10px;font-size:13px;">等级</label>
				<select id="user_level" name="user_level"  style="width: 100px;">
				<option value="0">全部</option>
				<?php
				foreach($levelList as $key=>$item){
				$selected = $item['id']==$user_level?'selected="true"':'';
				echo '<option '.$selected.' value="'. $item['id'].'">'. $item['user_level_name'].'</option>';
				}
				?>
				</select>
				
				<label style="padding-left:10px;font-size:13px;">起始时间：</label>
				<input type="text" class="Wdate " name="start_time" style="width: 150px;" value="<?= $start_time ?>" id="start_time" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
				<label style="padding-left:10px;font-size:13px;">结束时间：</label>
				<input type="text" class="Wdate " name="end_time" style="width: 150px;" value="<?= $end_time ?>" id="end_time" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
				<a style="padding-left:10px;" id="search">
					<button type="submit" class="btn btn-xs btn-success" style="height:28px;">
						<i class="icon-search nav-search-icon"></i>搜索
					</button>
				</a>
			</form>
			<input type="text" id="setUserIds" name="setUserIds" placeholder="起始id -分割" style="width: 100px;" value="" />
			<a style="padding-left:10px;" id="search">
				<button type="submit" class="btn btn-xs btn-info" style="height:28px;" onclick="resetData()">
					<i class="icon-repeat"></i>重置数据
				</button>
			</a>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<div class="table-header">
					会员业绩统计
				</div>
				<div class="table-responsive">
					<table id="sample-table-2" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th>账户</th>
								<th>姓名</th>
								<th>等级</th>
								<!-- <th>自己推荐业绩</th> -->
								<th>团队推荐业绩</th>
								<!-- <th>自己推荐人数</th> -->
								<th>团队推荐人数</th>

								<!-- <th>操作</th> -->
							</tr>
						</thead>
						<tfoot>
							<tr>
								<th>账户</th>
								<th>姓名</th>
								<th>等级</th>
								<!-- <th>自己推荐业绩</th> -->
								<th>团队推荐业绩</th>
								<!-- <th>自己推荐人数</th> -->
								<th>团队推荐人数</th>
								<!-- <th>操作</th> -->
							</tr>
						</tfoot>
					</table>
				</div><!-- /.table-responsive -->
			</div><!-- /span -->
		</div>
	</div>
</div>
<?php include_once('content.php'); ?>
<link rel="stylesheet" href="/public_source/www/assets/css/jquery-confirm.css" />
<link rel="stylesheet" href="/public_source/www/css/confirm.css" />
<script src="/public_source/www/assets/js/jquery.dataTables.min.js"></script>
<script src="/public_source/www/assets/js/jquery.dataTables.bootstrap.js"></script>
<script src="/public_source/www/assets/js/jquery-confirm.js"></script>
<script src="/public_source/www/My97DatePicker/WdatePicker.js"></script>
<script src="/public_source/www/js/charge.js"></script>
<?php include_once('footer.php'); ?>
<script type="text/javascript">
	jQuery(function($) {
		var username = $("#username").val();
		var user_level = $("#user_level").val();
		var tuandui = $("#tuandui").val();


		var user_id = $("#user_id").val();
		var start_time = $("#start_time").val();
		var end_time = $("#end_time").val();
		var oTable1 = $('#sample-table-2').dataTable({
			"oLanguage": {
				"sUrl": "/public_source/www/assets/language/zh_CN.json"
			},
			"aaSorting": [
				[3, "desc"]
			],
			"bAutoWidth": false,
			"bProcessing": true, //开启读取服务器数据时显示正在加载中……特别是大数据量的时候，开启此功能比较好
			"bServerSide": true, //开启服务器模式，使用服务器端处理配置datatable。注意：sAjaxSource参数也必须被给予为了给datatable源代码来获取所需的数据对于每个画。 这个翻译有点别扭。开启此模式后，你对datatables的每个操作 每页显示多少条记录、下一页、上一页、排序（表头）、搜索，这些都会传给服务器相应的值。 
			"sAjaxSource": "/admin/user_yeji/ajax_user_yeji_list?username=" + username + "&user_id=" + user_id + "&start_time=" + start_time + "&end_time=" + end_time+"&user_level="+user_level+"&tuandui="+tuandui, //给服务器发请求的url
			"aoColumns": [ //这个属性下的设置会应用到所有列，按顺序没有是空
				{
					"mData": 'username'
				}, //mData 表示发请求时候本列的列明，返回的数据中相同下标名字的数据会填充到这一列
				{
					"mData": 'true_name'
				},
				{
					"mData": 'user_level'
				},
				// {
				// 	"mData": 'zhitui'
				// },

				{
					"mData": 'tuandui'
				},
				// {
				// 	"mData": 'zhitui_num'
				// },
				{
					"mData": 'tuandui_num'
				},
				
			],
			"aoColumnDefs": [ //和aoColums类似，但他可以给指定列附近爱属性
				{
					"bSortable": false,
					"aTargets": [0, 1]
				}, //这句话意思是第1,3,6,7,8,9列（从0开始算） 不能排序
			]
		});
		$('[data-rel="tooltip"]').tooltip({
			placement: tooltip_placement
		});

		function tooltip_placement(context, source) {
			var $source = $(source);
			var $parent = $source.closest('table')
			var off1 = $parent.offset();
			var w1 = $parent.width();
			var off2 = $source.offset();
			var w2 = $source.width();
			if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
			return 'left';
		}
	});

	function resetData() {
		let setUserIds = $('#setUserIds').val();
		var path = "/admin/user_yeji/reset?keyword=" + setUserIds;

		$.confirm({
			title: '确定重置数据？',
			backgroundDismiss: false,
			content: '重置数据时间较长',
			confirm: function() {
				$.dialog({
					id: 'resetYejiLog',
					title: '重置会员业绩记录',
					backgroundDismiss: false,
					content: "<div id='resetYejiLogMsg'><div>正在重置会员业绩记录...</div></div>",
					width: 600,
					height: 400,
					onClose: function() {
						window.location.replace('/admin/user_yeji/index');
					}
				})
				$.ajax({
					async: true,
					url: path,
					type: "get",
					dataType: 'json',
					success: function(data) {
						$('#resetYejiLogMsg').append('<div>总共重置' + data.num + '个会员业绩记录</div>');
						// parent_path();
					}
				});
			}
		});
	}
</script>
<style>
	#sample-table-2_filter {
		display: none;
	}
</style>